$(function () {
    // 自定义验证规则
    let form = layui.form;
    form.verify({
        pwd: [/^[\S]{6,12}$/, '密码为6-12位!']
    })

    $("#form_login").on("submit", function (e) {
        e.preventDefault();
        $.ajax({
            url: '/admin/user/login',
            type: 'post',
            data: $(this).serialize(),
            success: (res) => {
                console.log(res);
                if (res.code !== 200) {
                    return layui.layer.msg(res.msg)
                }
                localStorage.setItem('token', res.token);
                location.href = '/index.html'
            }
        })
    })
})